/*
 * Echo.java
 *
 * Created on 29 octobre 2007, 15:37
 */
package com.reimscopie.console ;

import java.io.* ;


/**
 * This is the default echo command. The execution prints all arguments in
 * the output.
 */
public class Echo extends Command {
  
  /**
   * Create a new <code>Echo</code> instance.
   */
  public Echo() {
    
  }

  
  /**
   * Return the name of this command. The name is the first word in the shell
   * command line.
   *
   * @return <code>"echo"</code>.
   */
  public String getName() {
    return "echo" ;
  }
  
  
  /**
   * Return a short help message about this command.
   *
   * @return The command help.
   */
  public String getHelp() {
    return "Output the arguments" ;
  }
  
  
  /**
   * Return the command usage. This string must give all command options with
   * a description for each option.
   *
   * @return The command usage.
   */
  public String getUsage() {
    return "echo [arg ...]" ;
  }
  
  
  /**
   * Execute this command.
   *
   * @param args The arguments given in the command line.
   * @param output The command output.
   */
  public void execute(String[] args,ConsoleOutput output) {

    if (args == null)
      return ;
    
    output.print(args[0]) ;
    for (int i=1;i<args.length;i++) {
      output.print(' ') ;
      output.print(args[i]) ;
    }

    output.println() ;
    
  }
  
}
